package com.jz.community.modulemine.ui.view;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.ImageView;

import com.jz.community.modulemine.R;


/**
 * 自定义弹框
 *
 * @author qyy
 */
public class WinningCouponDialog extends AlertDialog {

    private int layout;
    Context context;
    ImageView image;

    public WinningCouponDialog(Context context) {
        super(context);
    }

    public WinningCouponDialog(Context context, int theme, int layout) {
        super(context, theme);
        this.context = context;
        this.layout = layout;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layout);
        image = (ImageView) findViewById(R.id.winning_bg);
    }

    private void gsetDecor() {
        Window window = getWindow();
        window.getDecorView().setPadding(0, 0, 0, 0);
        window.setGravity(Gravity.TOP);
        //获取屏幕宽高
//		WindowManager wm = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
//		WindowManager.LayoutParams lp = window.getAttributes();
//		lp.y = 120;
//		lp.width = (int)(wm.getDefaultDisplay().getWidth()* 0.7);
//		lp.height = (int)(wm.getDefaultDisplay().getHeight()* 0.67);
//		lp.dimAmount = 0.5f;
//		window.setAttributes(lp);
//        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

    }

    @Override
    public void show() {
        super.show();
        gsetDecor();
//        ObjectAnimator a=ObjectAnimator.ofFloat(image,"scaleY", 0f, 1.5f, 1f);
//        ObjectAnimator b=ObjectAnimator.ofFloat(image,"scaleX", 0f, 1.5f, 1f);
//        AnimatorSet set = new AnimatorSet();
//        set.play(a).with(b);
//        set.setDuration(500);
//        set.start();

//        Animation anim = new AnimationUtils().loadAnimation(context, R.anim.winning_coupon_anim);
//        anim.setFillAfter(true);//动画执行完毕后停留在最后一帧
//        image.startAnimation(anim);
    }
}
